<template>
    
     <div class="newsInfo-container">
      <h3 class="title">{{newsInfo.title}}</h3>

    
      <p class="info"> 
        <span>发表时间：{{newsInfo.add_time | dateFormat}}</span>
        <span>点击次数: {{newsInfo.click}}</span>
      
      </p>
      <hr>
      <div id="content" v-html="newsInfo.content">        
      </div>
       
       <comment :newsid="id"></comment>
    </div>
    
</template>

<script>
import comment from '../sub-conponents/Comment.vue'

export default {
    data(){
        return{
            newsInfo:{}
        };
    },
    methods:{
        async getNewsInfo(){
            console.log("ok");
         const{data} = await this.$http.get('api/getnew/'+this.id);
          //console.log(data);
        if (data.status === 0) return (this.newsInfo = data.message[0]);
        }
    },
    
    created(){
        console.log(this);
        this.getNewsInfo();
    },
    components:{
        comment:comment
    },  
    props:["id"]
   
};
</script>

<style lang="scss" scoped>
    
    .newsInfo-container{
        padding:10px;
        .title{
            color:red;
            font-size: 30px;
            text-align: center;
            margin:15px 0;
        }
        .info{
            color:blue;
            display:flex;
            justify-content: space-between;

        }


    }
    


</style>